package org.lex.swing.fontchooser.simple;

import java.awt.Font;

public class SimpleFontFactory {
	private String name = Font.DIALOG;
	private int style = Font.PLAIN;
	private int size = 12;

	public SimpleFontFactory() {
	}

	public SimpleFontFactory(String name, int style, int size) {
		super();
		this.name = name;
		this.style = style;
		this.size = size;
	}

	public Object get(SimpleFontAttribute attr) {
		switch (attr) {
		case FAMILY:
			return name;
		case STYLE:
			return style;
		case SIZE:
			return size;
		default:
			return null;
		}
	}

	public void set(SimpleFontAttribute attr, Object value) {
		switch (attr) {
		case FAMILY:
			name = value.toString();
			return;
		case STYLE:
			style = (Integer) value;
			return;
		case SIZE:
			size = (Integer) value;
			return;
		}
	}

	public Font newFont() {
		return new Font(name, style, size);
	}
}
